<?php
/**
 * Jobs Model for Jobs World Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_2
 * @license    GNU/GPL
 */
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.model' );
 
/**
 * Jobs Model
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class JobsModelDeactive extends JModel
{
	/**
	 * Category ata array
	 *
	 * @var array
	 */
	var $_data = null;

	/**
	 * Category total
	 *
	 * @var integer
	 */
	var $_total = null;

	/**
	 * Pagination object
	 *
	 * @var object
	 */
	var $_pagination = null;

	/**
	 * Constructor
	 *
	 * @since 1.5
	 */
	function __construct()
	{
		parent::__construct();

		global $mainframe, $option;
	}


	function setDeactiveJobs($id)
    {
		$db =& JFactory::getDBO();
	    $query = 'UPDATE #__jobs SET state = 0 WHERE id = '.$id;
	    $db->setQuery( $query );
	    $db->query();
		
      	@$this->sentMailDeactive('status@3malertilbud.dk',$id);
    }
	public function sentMailDeactive($email,$id)
		{
			
			//$html= "<br/>Hej:".$firma_navn;
			//$html= "ID :".$id;
			$html= "Kunden har slettet opgaven ID : ".$id;
			$html.= "<br/><br/>Med venlig hilsen,
					<br/><a href='http://www.3malertilbud.dk'><b>3malertilbud.dk</b></a
					<br/><a href='mailto:info@3malertilbud.dk'>info@3malertilbud.dk</a>";
			$html.= "<br/><img src='".JURI::root()."/templates/3dmaler/img/email_logo_footer.jpg'></img>";	
				
			$app		= JFactory::getApplication();	
			$mailfrom	= $app->getCfg('mailfrom');
			$fromname	= $app->getCfg('fromname');
			$sitename	= $app->getCfg('sitename');
			$name		= '';
			$email		= $email;
			
			$subject	= 'Kunden har slettet opgave ID : '.$id;
			$body		= $html;
			
			// Prepare email body
			//JURI::base();
			$body	= stripslashes($body);
			$mail = JFactory::getMailer();
			//echo $mailfrom;
			
			//echo $html;
			//exit();
			$mail->sendMail($mailfrom, $fromname, $email, $subject, $body, $mailfrom);	
			
		} 
}